/* obtain latest version of this script from http://code.google.com/p/foreigner-registration-hack/ */

/**
* @version 0.1
* @package Korean foreigner registation hack
* @authors: MaxC <max@max.tc>
* @created: January 27, 2010
*/

// ==UserScript==
// @name           Korean foreigner registation hack
// @namespace      http://max.tc
// @description    Disables client-side checking of your citizen/foreigner registration number
// ==/UserScript==

var activated = false;

if (typeof(unsafeWindow.check_jumin) == "function")
{
    unsafeWindow.check_jumin = function()
    {
        return true;
    }

    inform();
}

if (typeof(unsafeWindow.checkJumin) == "function")
{
    unsafeWindow.checkJumin = function()
    {
        return true;
    }

    inform();
}

if (typeof(unsafeWindow.f_chkJumin) == "function")
{
    unsafeWindow.f_chkJumin = function()
    {
        return true;
    }

    inform();
}

if (typeof(unsafeWindow.jumin_check) == "function")
{
    unsafeWindow.jumin_check = function()
    {
        return true;
    }

    inform();
}

if (typeof(unsafeWindow.check_juminno) == "function")
{
    unsafeWindow.check_juminno = function()
    {
        return true;
    }

    inform();
}

if (activated)
{
    var inputs = document.getElementsByTagName("INPUT");
    for (var i=0;i<inputs.length;i++) {
        if (inputs[i].type == "text")
        {
            inputs[i].maxLength = 100;
        }
    }
}

function inform()
{
    if (!activated)
    {
        activated = true;
        alert('The citizen/foreigner number validation on this web page has been disabled.  Please enter a valid number anyway.');
    }
}
